package com.itheima.controller;

import com.itheima.entity.Category;
import com.itheima.entity.Employee;
import com.itheima.entity.User;
import com.itheima.jsonresult.JsonResult;
import com.itheima.service.CategoryService;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户登录
     * @param user
     * @return
     */
    @PostMapping("/login")
    public JsonResult login(@RequestBody User user){
        return userService.login(user);
    }

    /**
     * 用户登出
     * @param request
     * @return
     */
    @PostMapping("/loginout")
    public JsonResult loginout(HttpServletRequest request){
        return userService.loginout(request);
    }

    /**
     * 发短信
     * @param user
     * @return
     */
    @PostMapping("/sendMsg")
    public JsonResult sendMsg(@RequestBody User user){
        return userService.sendMsg(user);
    }

}
